<!doctype html>
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
<title>保险预约</title>
<link href="../../css/newStyle.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../../js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script type="text/javascript" src="../../js/gbRst.js"></script>
<script type="text/javascript" src="../../js/utils.js"></script>
<script type="text/javascript" src="../../js/openId.js"></script>
<script type="text/javascript" src="../../js/header&footer.js"></script>
<!-- <script type="text/javascript" src="../../js/carService.js"></script>
 --><script type="text/javascript" src="../../js/doubleDate2.0.js"></script>
<script type="text/javascript" src="../../js/check.js"></script>
<script type="text/javascript" src="../../js/qmsk-1.2.js"></script>
<script type="text/javascript">

var memberId=0
var userId =0;
$(function(){
	$('.doubledate').kuiDate({
		className:'doubledate',
		isDisabled: "0"  // isDisabled为可选参数，“0”表示今日之前不可选，“1”标志今日之前可选
	});
	userId = getIdByName('id');
	var  user= _findInfo("../../../user/find/userById", {'id':getIdByName('id')});
	if(user.state==0){
		$("#dutyName").html(getHtmlString(getHeadIndexValue(0, user, "dutyName")))
		$("#dutyer").html(getHtmlString(getHeadIndexValue(0, user, "Name")))
		userId = getHtmlInt(getHeadIndexValue(0, user, "ID"));
	}
	var  member=_findInfo("../../../member/find/shopId/"+getShopId()+"/openId/"+getOpenId(), null)
	if(IsNotEmpty(member)&&member.state==0){
		if(member.result.data.length>0){
		$("#custName").val(getHtmlString(getHeadIndexValue(0, member, "CustomerName")))
		$("#mp").val(getHtmlString(getHeadIndexValue(0, member, "mp")))
			$("#License").val(getHtmlString(getHeadIndexValue(0, member, "license")))
	memberId=getHtmlString(getHeadIndexValue(0, member, "memberId"));
		}
	}
	var time = _findInfo("../../../insuranceCom/find/shopId/"+getShopId(), null)
	if(IsNotEmpty(time)&&time.state==0){
		for ( var i = 0; i < time.result.data.length; i++) {
			var htm="<option value='"+getHtmlInt(getHeadIndexValue(i, time, "Id"))+"'>"+getHtmlString(getHeadIndexValue(i, time, "Name"))+"</option>";
		$("#com").append(htm)
	}
	}
});

function save(){
	addInfo()
}

function addInfo(){
	var shopId = getShopId();
	var name= $("#custName").val();
	var mp= $("#mp").val().replace(/\s/gi,'');
	var CarTypeName= $("#CarTypeName").val();
	var dateTime= $("#OrderDate").val();
	var time= $("#com").val();
	var timeName= $("#com option:selected").text();
	var memo= $("#memo").val();
	var License = $("#License").val()
	if(!checkNull(name, "姓名", 'custName')||!_checkPhone(mp, false, '手机', 'mp')||!checkNull(dateTime, "预约日期", 'dateTime')||!checkNull(time, "保险公司", 'time')){
		return false;
	}
	var heads=new Array('shopId','CustomerID','CustomerName','LinkPhone','OrderDate','memo','userId','ComId','ComName','BillFrom','License','memberId')
	var datas=new Array(shopId,memberId,name,mp,dateTime,memo,userId,time,timeName,'WX',License,memberId)
	var params= _getJsonParseInsertStr(heads, datas);
	var dt=_insertInfoNoSucceedMessage("../../../insuranceRecord/insert/insertInfo", {'data':params});
	if(dt.state==0){
		alert("预约成功")
		restForm();
	}else{
		alert("预约失败")
	}
}

function restForm(){
	$("#OrderDate").val("");
	$("#memo").val("");
	$("#License").val("")
}

</script>
</head>

<body>
<div class="wrapper">
  <div class="container">
  		<p class="person">保险顾问：<br><span id="dutyer">张勇</span></p>
        <div class="person">
            姓名<span class="red">*</span><br>
            <input name="custName" id="custName" type="text" class="txt">
        </div>
        <div class="person">
            手机号<span class="red">*</span><br>
            <input name="mp" id="mp" type="text" class="txt">
        </div>
        <div class="person">
            车牌号码<span class="red">*</span><br>
            <input name="License" id="License" type="text" class="txt">
        </div>
        <div class="person">保险到期<span class="red">*</span><br><input type="text" id="OrderDate" class="txt mar doubledate" readonly><i class="appDate">保险公司<span class="red">*</span><br><select id="com"></select></i></div>
        <div class="person">
            备注	<br>
            <textarea id="memo"></textarea>
        </div>
        <div class="give">
            <input type="button" value="立即预约" class="giveBtn" onclick="save()">
        </div>
  </div>
</div>
</body>
</html>
